---
title: 'proxyWithHistory'
section: 'API'
subSection: 'Utils'
description: ''
---

# `proxyWithHistory`

## Keep a history of snapshots

This is a utility function to create a proxy with snapshot history.

```js
import { proxyWithHistory } from 'valtio-history'

const state = proxyWithHistory({ count: 0 })
console.log(state.value) // ---> { count: 0 }
state.value.count += 1
console.log(state.value) // ---> { count: 1 }
state.undo()
console.log(state.value) // ---> { count: 0 }
state.redo()
console.log(state.value) // ---> { count: 1 }
```

## Codesandbox demo

https://codesandbox.io/s/valtio-history-example-v0-m353xc?file=/src/App.tsx
